package spring;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mytest.demo.user.pojo.User;
import org.mytest.demo.user.service.IUserService;
import org.mytest.demo.user.service.impl.UserServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class Test {
	private static final Log log = LogFactory.getLog( Test.class );
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		log.info("Begin RUN !!!!!!");
		String paths = "conf/spring/applicationContext.xml";
		//这个xml文件是Spring配置beans的文件，路径 在整个应用的根目录
		ApplicationContext ctx = new ClassPathXmlApplicationContext(paths);
		log.info("Get CXT !!!!!!");
		MyBean myBean = (MyBean)ctx.getBean("myBean");
		//myBean是在Spring中注册的MyBean实现类的name或id
		//myBean.setName("Jason");
		log.info(myBean.getNewName());
		//------------------------------------------------
		IUserService userService = (UserServiceImpl)ctx.getBean("userService");
		User user = userService.getUserByID(916682882L);
		log.info(user.getName());

	}

}
